{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "536cdc2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Model\r\n",
      "metadata:\r\n",
      "  name: pandasquery\r\n",
      "spec:\r\n",
      "  storageUri: \"/mnt/models/pandasquery\"\r\n",
      "  requirements:\r\n",
      "  - mlserver\r\n",
      "  - python\r\n",
      "  parameters:\r\n",
      "  - name: query\r\n",
      "    value: \"A == 1\"\r\n"
     ]
    }
   ],
   "source": [
    "!cat model.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "84b1335d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f model.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "ee46e7dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1;39m{}\u001b[0m\r\n"
     ]
    }
   ],
   "source": [
    "!seldon model status pandasquery -w ModelAvailable | jq ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "ad445ade",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"pandasquery_1\",\r\n",
      "\t\"model_version\": \"1\",\r\n",
      "\t\"id\": \"df4e1e04-f66f-41e8-a09e-fcf7a1a17f36\",\r\n",
      "\t\"parameters\": {\r\n",
      "\t\t\"content_type\": null,\r\n",
      "\t\t\"headers\": null\r\n",
      "\t},\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"name\": \"status\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"BYTES\",\r\n",
      "\t\t\t\"parameters\": null,\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t\"no rows satisfied A == 2\"\r\n",
      "\t\t\t]\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon model infer pandasquery \\\n",
    "  '{\"inputs\": [{\"name\": \"A\", \"shape\": [1,3], \"datatype\": \"FP32\", \"data\": [4,1,3]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "a7636d9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon model unload pandasquery"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81b97ed1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
